function Gabor_cos = MakeGrating2( orient, numOfSamples, numOfCycles)
%parameters: 90,10,2
sd = 12;
 
orient = 2*pi - (orient*pi/180);
 
%create grading
step = 1/numOfSamples;
[x,y] = meshgrid( -pi:step:pi, -pi:step:pi);
ramp = (cos (orient) * x) - (sin(orient)*y);
 
im = sin(ramp*numOfCycles);
im_cos = cos(ramp*numOfCycles);

%Generate Gabor
filtSize = min(size(im));
x = linspace(-1, 1, filtSize) * filtSize/2;

y = (1/sqrt(2*pi*sd)).*exp(-.5*((x/sd).^2));
filt = (y'*y); filt = filt ./ max(filt(:)); %Gaussian


Gabor = im .* filt;

Gabor_cos = im_cos .* filt;
